fix(react-table): type column contexts with React table#6240
fix(react-table): type column contexts with React table#6240cyphercodes wants to merge 1 commit intoTanStack:alphafrom
Conversation
📝 WalkthroughWalkthroughThe PR refactors react-table's public API exports to be explicit rather than wildcard, introduces a new Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/react-table/tests/column-context.test-d.ts (1)
13-27: Consider adding afootercallback assertion for full coverage.
footercontext typing is also updated in this PR; adding one compile-time usage here would prevent regressions on that path too.Proposed test addition
const columns: Array<ColumnDef<typeof _features, Person>> = [ { accessorKey: 'name', header: ({ table }) => table.Subscribe({ selector: (state) => ({ globalFilter: state.globalFilter }), children: null, }), + footer: ({ table }) => + table.Subscribe({ + selector: (state) => ({ globalFilter: state.globalFilter }), + children: null, + }), cell: ({ table }) => table.Subscribe({ selector: (state) => ({ globalFilter: state.globalFilter }), children: null, }), }, ]🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/react-table/tests/column-context.test-d.ts` around lines 13 - 27, Add a compile-time assertion for the footer context by adding a footer callback to the existing ColumnDef in the test (the same columns array used for header and cell) that calls table.Subscribe with the same selector pattern (selector: (state) => ({ globalFilter: state.globalFilter }), children: null) so the footer context typing is exercised; update the ColumnDef<typeof _features, Person> entry for the 'name' column to include this footer callback to ensure the new footer typing is covered at compile time.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/react-table/tests/column-context.test-d.ts`:
- Around line 13-27: Add a compile-time assertion for the footer context by
adding a footer callback to the existing ColumnDef in the test (the same columns
array used for header and cell) that calls table.Subscribe with the same
selector pattern (selector: (state) => ({ globalFilter: state.globalFilter }),
children: null) so the footer context typing is exercised; update the
ColumnDef<typeof _features, Person> entry for the 'name' column to include this
footer callback to ensure the new footer typing is covered at compile time.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4858a4e2-ce44-4639-b473-893d17a3fd9e
📒 Files selected for processing (3)
packages/react-table/src/index.tspackages/react-table/src/useTable.tspackages/react-table/tests/column-context.test-d.ts
|
This kind of fixes the issue, but I fear that it can get pretty messy. There are lots more |
🎯 Changes
Fixes #6230.
cell,header, andfootercontexts so theirtableprop is the React table instance and exposes helpers liketable.Subscribe.ColumnDeffrom@tanstack/react-tableuses those React-specific contexts.table.Subscribeusage from both header and cell render callbacks.✅ Checklist
pnpm test:pr.Targeted checks run instead:
pnpm exec prettier --check packages/react-table/src/useTable.ts packages/react-table/src/index.ts packages/react-table/tests/column-context.test-d.tspnpm --filter @tanstack/react-table test:eslintpnpm --filter @tanstack/react-table test:typespnpm --filter @tanstack/react-table test:libpnpm --filter @tanstack/react-table buildgit diff --checkSummary by CodeRabbit
New Features
Refactor